#include "MouseStateManage.h"
#include "RGlobal.h"

std::string getCursorFromScene(int _x, int _y)
{
	MyGUI::IntSize size = mGUI->getViewSize();
	Ogre::Ray ray = mCamera->getCameraToViewportRay(
		_x / float(size.width),
		_y / float(size.height));
	gRaySceneQuery->setRay(ray);
	gRaySceneQuery->setSortByDistance(true);
	Ogre::RaySceneQueryResult &result = gRaySceneQuery->execute();
	for (Ogre::RaySceneQueryResult::iterator iter = result.begin(); iter!=result.end(); ++iter)
	{
		if (iter->movable != 0)
		{
			/*if (iter->movable->getName() == "enemy")
				return "enemy";
			else if (iter->movable->getName() == "friend")
				return "friend";*/
			return iter->movable->getName();
		}
	}

	return "default";
}

void CMouseStateManage::injectMouseMove(int _absx, int _absy, int _absz) 
{
	getCursorFromScene(_absx, _absy);
}
void CMouseStateManage::injectMousePress(int _absx, int _absy, MyGUI::MouseButton _id) 
{

}
void CMouseStateManage::injectMouseRelease(int _absx, int _absy, MyGUI::MouseButton _id) 
{ 

}
void CMouseStateManage::injectKeyPress(MyGUI::KeyCode _key, MyGUI::Char _text) 
{ 

}
void CMouseStateManage::injectKeyRelease(MyGUI::KeyCode _key) 
{ 

}